package cn.qidd.keep.order.model.order;

import cn.qidd.keep.domain.document.Order;
import cn.qidd.keep.domain.document.QOrder;
import cn.qidd.keep.domain.model.BaseSearch;
import com.querydsl.core.BooleanBuilder;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class OrderSearchParam extends BaseSearch {

    @ApiModelProperty("订单编号")
    private String orderNo;
    @ApiModelProperty("客户姓名")
    private String name;
    @ApiModelProperty("手机号码")
    private String phone;

    @Override
    public BooleanBuilder generateSearchCondition() {
        BooleanBuilder builder = new BooleanBuilder();
        QOrder qOrder = QOrder.order;
        if (StringUtils.isNotBlank(this.orderNo))
            builder.and(qOrder.orderNo.eq(this.orderNo));
        if (StringUtils.isNotBlank(this.name))
            builder.and(qOrder.name.eq(this.name));
        if (StringUtils.isNotBlank(this.phone))
            builder.and(qOrder.phone.eq(this.phone));
        return builder;
    }
}
